home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / edit / thesrc20.zip / comm3.c < prev    next >
C/C++ Source or Header  |  1995-01-26  |  41KB  |  1,298 lines

  1. /***********************************************************************/
  2. /* COMM3.C - Commands K-O                                              */
  3. /* This file contains all commands that can be assigned to function    */
  4. /* keys or typed on the command line.                                  */
  5. /***********************************************************************/
  6. /*
  7.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  8.  * Copyright (C) 1991-1995 Mark Hessling
  9.  *
  10.  * This program is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU General Public License as
  12.  * published by the Free Software Foundation; either version 2 of
  13.  * the License, or any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18.  * General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to:
  22.  *
  23.  *    The Free Software Foundation, Inc.
  24.  *    675 Mass Ave,
  25.  *    Cambridge, MA 02139 USA.
  26.  *
  27.  *
  28.  * If you make modifications to this software that you feel increases
  29.  * it usefulness for the rest of the community, please email the
  30.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  31.  * This software is going to be maintained and enhanced as deemed
  32.  * necessary by the community.
  33.  *
  34.  * Mark Hessling                     email: M.Hessling@gu.edu.au
  35.  * 36 David Road                     Phone: +61 7 849 7731
  36.  * Holland Park                      Fax:   +61 7 875 5314
  37.  * QLD 4121
  38.  * Australia
  39.  */
  40.  
  41. /*
  42. $Id: comm3.c 2.0 1995/01/26 16:29:56 MH Release MH $
  43. */
  44.  
  45. #include <stdio.h>
  46.  
  47. #include "the.h"
  48. #include "proto.h"
  49.  
  50. /*#define DEBUG 1*/
  51.  
  52. /*man-start*********************************************************************
  53. COMMAND
  54.      left - scroll the screen to the left
  55.  
  56. SYNTAX
  57.      LEft [n|HALF]
  58.  
  59. DESCRIPTION
  60.      The LEFT command scrolls the screen n columns to the left.
  61.      If no parameter is supplied, the screen is scrolled by one
  62.      column. If HALF is specified the screen is scrolled by half 
  63.      the number of columns in the FILEAREA.
  64.  
  65. COMPATIBILITY
  66.      XEDIT: Compatible.
  67.      KEDIT: Compatible.
  68.  
  69. SEE ALSO
  70.      RIGHT, RGTLEFT
  71.  
  72. STATUS
  73.      Complete.
  74. **man-end**********************************************************************/
  75. #ifdef PROTO
  76. short Left(CHARTYPE *params)
  77. #else
  78. short Left(params)
  79. CHARTYPE *params;
  80. #endif
  81. /***********************************************************************/
  82. {
  83. /*-------------------------- external data ----------------------------*/
  84. /*--------------------------- local data ------------------------------*/
  85.  short rc=RC_OK;
  86.  LINETYPE shift_val=1L;
  87. /*--------------------------- processing ------------------------------*/
  88. #ifdef TRACE
  89.  trace_function("comm3.c:   Left");
  90. #endif
  91. /*---------------------------------------------------------------------*/
  92. /* Validate only parameter, HALF or positive integer. 1 if no argument.*/
  93. /*---------------------------------------------------------------------*/
  94.  if (equal(params,(CHARTYPE *)"half",4))
  95.     shift_val = -(CURRENT_SCREEN.cols[WINDOW_MAIN]/2);
  96.  if (blank_field(params))
  97.     shift_val = (-1L);
  98.  if (shift_val == 1)                 /* argument not HALF or empty ... */
  99.    {
  100.     if (valid_positive_integer(params))
  101.       {
  102.        shift_val = atol(params);
  103.        if (shift_val != 0)
  104.           shift_val = -shift_val;
  105.       }
  106.    }
  107.  if (shift_val == 1)                               /* invalid argument */
  108.    {
  109.     display_error(1,params,FALSE);
  110. #ifdef TRACE
  111.     trace_return();
  112. #endif
  113.     return(RC_INVALID_OPERAND);
  114.    }
  115. /*---------------------------------------------------------------------*/
  116. /* If the argument is 0, restore the original verify columns display.  */
  117. /*---------------------------------------------------------------------*/
  118.  if (shift_val == 0L)
  119.     CURRENT_VIEW->verify_col = CURRENT_VIEW->verify_start;
  120.  else
  121.     CURRENT_VIEW->verify_col = max(1,CURRENT_VIEW->verify_col+shift_val);
  122.  build_current_screen();
  123.  display_current_screen();
  124. #ifdef TRACE
  125.  trace_return();
  126. #endif
  127.  return(rc);
  128. }
  129. /*man-start*********************************************************************
  130. COMMAND
  131.      locate - search for a target
  132.  
  133. SYNTAX
  134.      [Locate] target [command]
  135.  
  136. DESCRIPTION
  137.      The LOCATE command searches for the next or previous occurrence 
  138.      of the specified target.  If no parameter is supplied, LOCATE
  139.      uses the the last target specified. If no prior target has been
  140.      specified, an error message is displayed. With an optional operand, 
  141.      it executes the command after finding the target.
  142.  
  143. COMPATIBILITY
  144.      XEDIT: Compatible.
  145.      KEDIT: Compatible.
  146.  
  147. STATUS
  148.      Complete.
  149. **man-end**********************************************************************/
  150. #ifdef PROTO
  151. short Locate(CHARTYPE *params)
  152. #else
  153. short Locate(params)
  154. CHARTYPE *params;
  155. #endif
  156. /***********************************************************************/
  157. {
  158. /*-------------------------- external data ----------------------------*/
  159.  extern CHARTYPE *last_target;
  160. /*--------------------------- local data ------------------------------*/
  161.  short rc=RC_OK;
  162. /*--------------------------- processing ------------------------------*/
  163. #ifdef TRACE
  164.  trace_function("comm3.c:   Locate");
  165. #endif
  166. /*---------------------------------------------------------------------*/
  167. /* If no parameter is specified, use the last_target. If that doesn't  */
  168. /* exist, error.                                                       */
  169. /*---------------------------------------------------------------------*/
  170.  if (strcmp(params,"") == 0)
  171.    {
  172.     if (strcmp(last_target,"") == 0)
  173.       {
  174.        display_error(39,(CHARTYPE *)"",FALSE);
  175. #ifdef TRACE
  176.        trace_return();
  177. #endif
  178.        return(RC_INVALID_OPERAND);
  179.       }
  180.     rc = command_line(last_target,COMMAND_ONLY_FALSE);
  181. #ifdef TRACE
  182.     trace_return();
  183. #endif
  184.     return(rc);
  185.    }
  186.  rc = command_line(params,COMMAND_ONLY_FALSE);
  187. #ifdef TRACE
  188.  trace_return();
  189. #endif
  190.  return(rc);
  191. }
  192. /*man-start*********************************************************************
  193. COMMAND
  194.      lowercase - change uppercase characters to lowercase
  195.  
  196. SYNTAX
  197.      LOWercase [target]
  198.  
  199. DESCRIPTION
  200.      The LOWERCASE command changes all uppercase characters in all 
  201.      lines up to the target line to lowercase. All other characters 
  202.      remain untouched.
  203.  
  204. COMPATIBILITY
  205.      XEDIT: Equivalent of LOWERCAS command.
  206.      KEDIT: Compatible.
  207.  
  208. SEE ALSO
  209.      UPPERCASE
  210.  
  211. STATUS
  212.      Complete.
  213. **man-end**********************************************************************/
  214. #ifdef PROTO
  215. short Lowercase(CHARTYPE *params)
  216. #else
  217. short Lowercase(params)
  218. CHARTYPE *params;
  219. #endif
  220. /***********************************************************************/
  221. {
  222. /*--------------------------- local data ------------------------------*/
  223.  short rc=RC_OK;
  224. /*--------------------------- processing ------------------------------*/
  225. #ifdef TRACE
  226.  trace_function("comm3.c:   Lowercase");
  227. #endif
  228.  rc = execute_change_case(params,CASE_LOWER);
  229. #ifdef TRACE
  230.  trace_return();
  231. #endif
  232.  return(rc);
  233. }
  234. /*man-start*********************************************************************
  235. COMMAND
  236.      ls - list the specified directory as an editable file
  237.  
  238. SYNTAX
  239.      LS [filespec]
  240.  
  241. DESCRIPTION
  242.      The LS command displays all files matching the specified
  243.      file specification.
  244.      When no parameter is supplied, all files in the current directory 
  245.      are displayed subject to any SET DIRINCLUDE restrictions.
  246.  
  247. COMPATIBILITY
  248.      XEDIT: N/A
  249.      KEDIT: Compatible.
  250.  
  251. SEE ALSO
  252.      DIRECTORY, SET DIRINCLUDE
  253.  
  254. STATUS
  255.      Complete.
  256. **man-end**********************************************************************/
  257.  
  258. /*man-start*********************************************************************
  259. COMMAND
  260.      macro - execute a macro command file
  261.  
  262. SYNTAX
  263.      MACRO filename [arguments]
  264.  
  265. DESCRIPTION
  266.      The MACRO command executes the contents of the specified file
  267.      as command line commands.
  268.  
  269. COMPATIBILITY
  270.      XEDIT: Compatible.
  271.      KEDIT: Compatible.
  272.      Only REXX macros accept the passing of arguments to the macro file.
  273.  
  274. STATUS
  275.      Complete.
  276. **man-end**********************************************************************/
  277. #ifdef PROTO
  278. short Macro(CHARTYPE *params)
  279. #else
  280. short Macro(params)
  281. CHARTYPE *params;
  282. #endif
  283. /***********************************************************************/
  284. {
  285. /*-------------------------- external data ----------------------------*/
  286. /*--------------------------- local data ------------------------------*/
  287.  short rc=RC_OK;
  288. /*--------------------------- processing ------------------------------*/
  289. #ifdef TRACE
  290.  trace_function("comm3.c:   Macro");
  291. #endif
  292.  rc = execute_macro(params,TRUE);
  293. #ifdef TRACE
  294.  trace_return();
  295. #endif
  296.  return(rc);
  297. }
  298. /*man-start*********************************************************************
  299. COMMAND
  300.      mark - mark a portion of text
  301.  
  302. SYNTAX
  303.      MARK Line|Box|Stream|Word|Column
  304.  
  305. DESCRIPTION
  306.      The MARK command marks a portion of text for later processing
  307.      by a COPY, MOVE or DELETE command.
  308.  
  309. COMPATIBILITY
  310.      XEDIT: N/A
  311.      KEDIT: Does not implement Stream.
  312.             Adds WORD option and COLUMN options.
  313.  
  314. STATUS
  315.      Complete.
  316. **man-end**********************************************************************/
  317. #ifdef PROTO
  318. short Mark(CHARTYPE *params)
  319. #else
  320. short Mark(params)
  321. CHARTYPE *params;
  322. #endif
  323. /***********************************************************************/
  324. {
  325. /*-------------------------- external data ----------------------------*/
  326.  extern VIEW_DETAILS *vd_mark;
  327.  extern CHARTYPE *rec;
  328.  extern LENGTHTYPE rec_len;
  329. /*--------------------------- local data ------------------------------*/
  330.  LINETYPE true_line=0L;
  331.  unsigned short y=0,x=0;
  332.  unsigned short real_col=0;
  333.  bool type_param=FALSE;
  334.  LENGTHTYPE first_col=0,last_col=0;
  335. /*--------------------------- processing ------------------------------*/
  336. #ifdef TRACE
  337.  trace_function("comm3.c:   Mark");
  338. #endif
  339. /*---------------------------------------------------------------------*/
  340. /* Marking text sets the following variables:                          */
  341. /* LINE:                                                               */
  342. /*         CURRENT_VIEW->marked_line:       TRUE                       */
  343. /*         CURRENT_VIEW->marked_start_line: line number of first line  */
  344. /*         CURRENT_VIEW->marked_end_line:   line number of last line   */
  345. /*         CURRENT_VIEW->marked_col:        FALSE                      */
  346. /*         CURRENT_VIEW->marked_start_col:  (ignored)                  */
  347. /*         CURRENT_VIEW->marked_end_col:    (ignored)                  */
  348. /* BOX:                                                                */
  349. /* STREAM:                                                             */
  350. /* WORD:                                                               */
  351. /*         CURRENT_VIEW->marked_line:       TRUE                       */
  352. /*         CURRENT_VIEW->marked_start_line: line number of first line  */
  353. /*         CURRENT_VIEW->marked_end_line:   line number of last line   */
  354. /*         CURRENT_VIEW->marked_col:        TRUE                       */
  355. /*         CURRENT_VIEW->marked_start_col:  first column               */
  356. /*         CURRENT_VIEW->marked_end_col:    last column                */
  357. /* COLUMN:                                                             */
  358. /*         CURRENT_VIEW->marked_line:       FALSE                      */
  359. /*         CURRENT_VIEW->marked_start_line: (ignored)                  */
  360. /*         CURRENT_VIEW->marked_end_line:   (ignored)                  */
  361. /*         CURRENT_VIEW->marked_col:        TRUE                       */
  362. /*         CURRENT_VIEW->marked_start_col:  first column               */
  363. /*         CURRENT_VIEW->marked_end_col:    last column                */
  364. /*---------------------------------------------------------------------*/
  365. /* Validate the argument...                                            */
  366. /*---------------------------------------------------------------------*/
  367.  if (equal(params,(CHARTYPE *)"line",1))
  368.     type_param = M_LINE;
  369.  if (equal(params,(CHARTYPE *)"box",1))
  370.     type_param = M_BOX;
  371.  if (equal(params,(CHARTYPE *)"word",1))
  372.     type_param = M_WORD;
  373.  if (equal(params,(CHARTYPE *)"column",1))
  374.     type_param = M_COLUMN;
  375.  if (type_param == 0)
  376.    {
  377.     display_error(1,params,FALSE);
  378. #ifdef TRACE
  379.     trace_return();
  380. #endif
  381.     return(RC_INVALID_OPERAND);
  382.    }
  383.  true_line = get_true_line();
  384. /*---------------------------------------------------------------------*/
  385. /* If we are on 'Top of File' or 'Bottom of File' lines, error.        */
  386. /*---------------------------------------------------------------------*/
  387.  if (TOF(true_line) || BOF(true_line))
  388.    {
  389.     display_error(38,(CHARTYPE *)"",FALSE);
  390. #ifdef TRACE
  391.     trace_return();
  392. #endif
  393.     return(RC_INVALID_ENVIRON);
  394.    }
  395. /*---------------------------------------------------------------------*/
  396. /* If we are in the file area or prefix area and the focus line is not */
  397. /* a real line, error.                                                 */
  398. /*---------------------------------------------------------------------*/
  399.  getyx(CURRENT_WINDOW,y,x);
  400.  if (CURRENT_VIEW->current_window == WINDOW_MAIN
  401.  ||  CURRENT_VIEW->current_window == WINDOW_PREFIX)
  402.    {
  403.     if (CURRENT_SCREEN.sl[y].line_type != LINE_LINE)
  404.       {
  405.        display_error(38,(CHARTYPE *)"",FALSE);
  406. #ifdef TRACE
  407.        trace_return();
  408. #endif
  409.        return(RC_INVALID_ENVIRON);
  410.       }
  411.    }
  412. /*---------------------------------------------------------------------*/
  413. /* Reset the previous marked view...                                   */
  414. /*---------------------------------------------------------------------*/
  415.  if (MARK_VIEW != (VIEW_DETAILS *)NULL
  416.  &&  MARK_VIEW != CURRENT_VIEW)
  417.     MARK_VIEW->marked_line = MARK_VIEW->marked_col = FALSE;
  418.  MARK_VIEW = CURRENT_VIEW;
  419.  CURRENT_VIEW->mark_type = type_param;
  420. /*---------------------------------------------------------------------*/
  421. /* Set the new values for top and bottom lines marked.                 */
  422. /*---------------------------------------------------------------------*/
  423.  if (CURRENT_VIEW->marked_line)
  424.    {
  425.     if (true_line > CURRENT_VIEW->mark_end_line)
  426.        CURRENT_VIEW->mark_end_line = true_line;
  427.     if (true_line < CURRENT_VIEW->mark_start_line)
  428.        CURRENT_VIEW->mark_start_line = true_line;
  429.     if (true_line < CURRENT_VIEW->mark_end_line
  430.     &&  true_line > CURRENT_VIEW->mark_start_line)
  431.       {
  432.        if (true_line-CURRENT_VIEW->mark_end_line >
  433.            CURRENT_VIEW->mark_start_line-true_line)
  434.           CURRENT_VIEW->mark_end_line = true_line;
  435.        else
  436.           CURRENT_VIEW->mark_start_line = true_line;
  437.       }
  438.    }
  439.  else
  440.    {
  441.     CURRENT_VIEW->mark_start_line = CURRENT_VIEW->mark_end_line = true_line;
  442.    }
  443. /*---------------------------------------------------------------------*/
  444. /* Set the new values for first and last columns marked.               */
  445. /*---------------------------------------------------------------------*/
  446.  real_col = x + CURRENT_VIEW->verify_col;
  447.  if (CURRENT_VIEW->marked_col)
  448.    {
  449.     if ((real_col) > CURRENT_VIEW->mark_end_col)
  450.        CURRENT_VIEW->mark_end_col = (real_col);
  451.     if ((real_col) < CURRENT_VIEW->mark_start_col)
  452.        CURRENT_VIEW->mark_start_col = (real_col);
  453.     if ((real_col) < CURRENT_VIEW->mark_end_col
  454.     &&  (real_col) > CURRENT_VIEW->mark_start_col)
  455.       {
  456.        if ((real_col)-CURRENT_VIEW->mark_end_col > CURRENT_VIEW->mark_start_col-(real_col))
  457.           CURRENT_VIEW->mark_end_col = (real_col);
  458.        else
  459.           CURRENT_VIEW->mark_start_col = (real_col);
  460.       }
  461.    }
  462.  else
  463.    {
  464.     CURRENT_VIEW->mark_start_col = CURRENT_VIEW->mark_end_col = real_col;
  465.    }
  466. /*---------------------------------------------------------------------*/
  467. /* Set flags for various marked text types...                          */
  468. /*---------------------------------------------------------------------*/
  469.  switch(type_param)
  470.    {
  471.     case M_LINE:
  472.          CURRENT_VIEW->marked_col = FALSE;
  473.          CURRENT_VIEW->marked_line = TRUE;
  474.          break;
  475.     case M_BOX:
  476.          CURRENT_VIEW->marked_col = TRUE;
  477.          CURRENT_VIEW->marked_line = TRUE;
  478.          break;
  479.     case M_WORD:
  480.          if (get_word(rec,rec_len,real_col-1,&first_col,&last_col) == 0)
  481.            {
  482.             CURRENT_VIEW->marked_line = CURRENT_VIEW->marked_col = FALSE;
  483.             MARK_VIEW = (VIEW_DETAILS *)NULL;
  484.             break;
  485.            }
  486.          CURRENT_VIEW->marked_col = TRUE;
  487.          CURRENT_VIEW->marked_line = TRUE;
  488.          CURRENT_VIEW->mark_start_line = CURRENT_VIEW->mark_end_line = true_line;
  489.          CURRENT_VIEW->mark_start_col = first_col+1;
  490.          CURRENT_VIEW->mark_end_col = last_col+1;
  491.          break;
  492.     case M_COLUMN:
  493.          CURRENT_VIEW->marked_line = FALSE;
  494.          CURRENT_VIEW->marked_col = TRUE;
  495.          CURRENT_VIEW->mark_start_line = 1L;
  496.          CURRENT_VIEW->mark_end_line = MAX_LONG;
  497.          break;
  498.     case M_STREAM:
  499.          CURRENT_VIEW->marked_col = TRUE;
  500.          CURRENT_VIEW->marked_line = TRUE;
  501.          break;
  502.    }
  503.  build_current_screen(); 
  504.  display_current_screen();
  505.  wmove(CURRENT_WINDOW,y,x);
  506. #ifdef TRACE
  507.  trace_return();
  508. #endif
  509.  return(RC_OK);
  510. }
  511. /*man-start*********************************************************************
  512. COMMAND
  513.      modify - display current SET command for alteration
  514.  
  515. SYNTAX
  516.      MODify set-command
  517.  
  518. DESCRIPTION
  519.      The MODIFY command displays the current setting of a set command
  520.      on the command line enabling the user to change that setting.
  521.  
  522. COMPATIBILITY
  523.      XEDIT: Compatible.
  524.      KEDIT: Compatible.
  525.  
  526. SEE ALSO
  527.      SET, QUERY
  528.  
  529. STATUS
  530.      Complete.
  531. **man-end**********************************************************************/
  532. #ifdef PROTO
  533. short Modify(CHARTYPE *params)
  534. #else
  535. short Modify(params)
  536. CHARTYPE *params;
  537. #endif
  538. /***********************************************************************/
  539. {
  540. /*-------------------------- external data ----------------------------*/
  541.  extern VALUE item_values[18];
  542.  extern CHARTYPE *temp_cmd;
  543. /*--------------------------- local data ------------------------------*/
  544.  register short i=0;
  545.  short itemno=0;
  546. /*--------------------------- processing ------------------------------*/
  547. #ifdef TRACE
  548.  trace_function("comm3.c:   Modify");
  549. #endif
  550.  if ((itemno = find_item(params,QUERY_MODIFY)) == (-1))
  551.     {
  552.      display_error(1,params,FALSE);
  553. #ifdef TRACE
  554.      trace_return();
  555. #endif
  556.      return(RC_INVALID_OPERAND);
  557.     }
  558.  
  559.  itemno = get_item_values(itemno,(CHARTYPE *)"",QUERY_MODIFY,0L,NULL,0L);
  560.  strcpy(temp_cmd,"set ");
  561.  for (i=0;i<itemno+1;i++)
  562.    {
  563.     strcat(temp_cmd,item_values[i].value);
  564.     strcat(temp_cmd," ");
  565.    }
  566.  Cmsg(temp_cmd);
  567. #ifdef TRACE
  568.  trace_return();
  569. #endif
  570.  return(RC_OK);
  571. }
  572. /*man-start*********************************************************************
  573. COMMAND
  574.      move - move a portion of text
  575.  
  576. SYNTAX
  577.      MOVE BLOCK [RESET]
  578.  
  579. DESCRIPTION
  580.      The MOVE command copies the contents of the marked block to the
  581.      current cursor position and deletes the characters/lines from the
  582.      original position of the marked block.
  583.  
  584. COMPATIBILITY
  585.      XEDIT: N/A
  586.      KEDIT: Adds extra functionality with [RESET] option.
  587.  
  588. STATUS
  589.      Complete.
  590. **man-end**********************************************************************/
  591. #ifdef PROTO
  592. short THEMove(CHARTYPE *params)
  593. #else
  594. short THEMove(params)
  595. CHARTYPE *params;
  596. #endif
  597. /***********************************************************************/
  598. {
  599. /*-------------------------- external data ----------------------------*/
  600.  extern VIEW_DETAILS *vd_mark;
  601. /*--------------------------- local data ------------------------------*/
  602. #define MOV_PARAMS 2
  603.  CHARTYPE *word[MOV_PARAMS+1];
  604.  unsigned short num_params=0;
  605.  unsigned short y=0,x=0;
  606.  LINETYPE true_line=0L;
  607.  CHARTYPE reset_block=SOURCE_UNKNOWN;
  608.  CHARTYPE copy_command=0,delete_command=0;
  609.  short rc=RC_OK;
  610.  LINETYPE start_line=0L,end_line=0L,num_lines=0L,dest_line=0L;
  611.  VIEW_DETAILS *old_mark_view=NULL;
  612. /*--------------------------- processing ------------------------------*/
  613. #ifdef TRACE
  614.  trace_function("comm3.c:   THEMove");
  615. #endif
  616.  num_params = param_split(params,word,MOV_PARAMS,WORD_DELIMS,TEMP_PARAM);
  617.  if (num_params == 0)
  618.     {
  619.      display_error(3,(CHARTYPE *)"",FALSE);
  620. #ifdef TRACE
  621.      trace_return();
  622. #endif
  623.      return(RC_INVALID_OPERAND);
  624.     }
  625.  if (num_params > 2)
  626.     {
  627.      display_error(2,(CHARTYPE *)"",FALSE);
  628. #ifdef TRACE
  629.      trace_return();
  630. #endif
  631.      return(RC_INVALID_OPERAND);
  632.     }
  633. /*---------------------------------------------------------------------*/
  634. /* Test for valid parameters...                                        */
  635. /*---------------------------------------------------------------------*/
  636.  if (num_params == 1
  637.  &&  equal((CHARTYPE *)"block",word[0],5))
  638.     reset_block = SOURCE_BLOCK;
  639.  if (num_params == 2
  640.  &&  equal((CHARTYPE *)"block",word[0],5)
  641.  &&  equal((CHARTYPE *)"reset",word[1],5))
  642.     reset_block = SOURCE_BLOCK_RESET;
  643.  if (reset_block == SOURCE_UNKNOWN)
  644.     {
  645.      display_error(1,params,FALSE);
  646. #ifdef TRACE
  647.      trace_return();
  648. #endif
  649.      return(RC_INVALID_OPERAND);
  650.     }
  651. /*---------------------------------------------------------------------*/
  652. /* Validate marked block, can be in any view.                          */
  653. /*---------------------------------------------------------------------*/
  654.  if (marked_block(FALSE) != RC_OK)
  655.    {
  656. #ifdef TRACE
  657.     trace_return();
  658. #endif
  659.     return(RC_INVALID_ENVIRON);
  660.    }
  661. /*---------------------------------------------------------------------*/
  662. /* If the cursor is in the marked block...error.                       */
  663. /*---------------------------------------------------------------------*/
  664.  if (MARK_VIEW == CURRENT_VIEW)
  665.    {
  666.     getyx(CURRENT_WINDOW_MAIN,y,x);
  667.     switch(MARK_VIEW->mark_type)
  668.       {
  669.        case M_LINE:
  670.                    if ((CURRENT_VIEW->focus_line >= MARK_VIEW->mark_start_line)
  671.                    &&  (CURRENT_VIEW->focus_line <= MARK_VIEW->mark_end_line))
  672.                      {
  673.                       display_error(44,(CHARTYPE *)"for line move",FALSE);
  674. #ifdef TRACE
  675.                       trace_return();
  676. #endif
  677.                       return(RC_INVALID_ENVIRON);
  678.                      }
  679.                    break;
  680.        case M_BOX:
  681.                    if ((CURRENT_VIEW->focus_line >= MARK_VIEW->mark_start_line)
  682.                    &&  (CURRENT_VIEW->focus_line <= MARK_VIEW->mark_end_line)
  683.                    &&  (x + CURRENT_VIEW->verify_col >= MARK_VIEW->mark_start_col)
  684.                    &&  (x + CURRENT_VIEW->verify_col <= MARK_VIEW->mark_end_col))
  685.                      {
  686.                       display_error(50,(CHARTYPE *)"",FALSE);
  687. #ifdef TRACE
  688.                       trace_return();
  689. #endif
  690.                       return(RC_INVALID_ENVIRON);
  691.                      }
  692.                    break;
  693.        default:
  694.                    break;
  695.       }
  696.    }
  697. /*---------------------------------------------------------------------*/
  698. /* If block is a box, call its function.                               */
  699. /*---------------------------------------------------------------------*/
  700.  if (MARK_VIEW->mark_type == M_BOX)
  701.    {
  702.     box_operations(BOX_M,reset_block,FALSE,' ');/* don't reset and don't overlay */
  703. #ifdef TRACE
  704.     trace_return();
  705. #endif
  706.     return(RC_OK);
  707.    }
  708. /*---------------------------------------------------------------------*/
  709. /* Determine the target line. If on the command line, target is current*/
  710. /* line, else target line is focus line.                               */
  711. /*---------------------------------------------------------------------*/
  712.  true_line = get_true_line();
  713. /*---------------------------------------------------------------------*/
  714. /* If the true  line is the bottom of file line, subtract 1 from it.   */
  715. /*---------------------------------------------------------------------*/
  716.  if (BOF(true_line))
  717.     true_line--;
  718.  
  719.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  720.  start_line = MARK_VIEW->mark_start_line;
  721.  end_line = MARK_VIEW->mark_end_line;
  722.  num_lines = end_line - start_line + 1L;
  723.  dest_line = true_line;
  724.  old_mark_view = MARK_VIEW;
  725.  if (MARK_VIEW == CURRENT_VIEW)
  726.    {
  727.     copy_command = COMMAND_MOVE_COPY_SAME;
  728.     delete_command = COMMAND_MOVE_DELETE_SAME;
  729.    }
  730.  else
  731.    {
  732.     copy_command = COMMAND_MOVE_COPY_DIFF;
  733.     delete_command = COMMAND_MOVE_DELETE_DIFF;
  734.    }
  735.  
  736.  rc = rearrange_line_blocks(copy_command,reset_block,start_line,
  737.                             end_line,dest_line,1,MARK_VIEW,CURRENT_VIEW,FALSE);
  738.  if (rc == RC_OK)
  739.    {
  740.     if (old_mark_view == CURRENT_VIEW)
  741.       {
  742.        if (dest_line < start_line)
  743.          {
  744.           start_line += num_lines;
  745.           end_line += num_lines;
  746.           dest_line += num_lines;
  747.          }
  748.       }
  749.     post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  750.     rc = rearrange_line_blocks(delete_command,reset_block,start_line,
  751.                             end_line,start_line,1,old_mark_view,old_mark_view,FALSE);
  752.    }
  753. #ifdef TRACE
  754.  trace_return();
  755. #endif
  756.  return(rc);
  757. }
  758. /*man-start*********************************************************************
  759. COMMAND
  760.      msg - display message on error line
  761.  
  762. SYNTAX
  763.      MSG [message]
  764.  
  765. DESCRIPTION
  766.      The MSG command displays an error message on the error line.
  767.      This command is usually issued from a macro file.
  768.      This is similar to EMSG, but MSG does not sound the bell if SET
  769.      BELL is on.
  770.  
  771. COMPATIBILITY
  772.      XEDIT: Compatible.
  773.      KEDIT: Compatible.
  774.  
  775. SEE ALSO
  776.      CMSG, EMSG
  777.  
  778. STATUS
  779.      Complete.
  780. **man-end**********************************************************************/
  781. #ifdef PROTO
  782. short Msg(CHARTYPE *params)
  783. #else
  784. short Msg(params)
  785. CHARTYPE *params;
  786. #endif
  787. /***********************************************************************/
  788. {
  789. /*-------------------------- external data ----------------------------*/
  790. extern WINDOW *error_window;
  791. /*--------------------------- local data ------------------------------*/
  792. /*--------------------------- processing ------------------------------*/
  793. #ifdef TRACE
  794.  trace_function("comm3.c:   Msg");
  795. #endif
  796.  display_error(0,params,TRUE);
  797.  touchwin(error_window);
  798.  wrefresh(error_window);
  799. #ifdef TRACE
  800.  trace_return();
  801. #endif
  802.  return(RC_OK);
  803. }
  804. /*man-start*********************************************************************
  805. COMMAND
  806.      next - move forward in the file a number of lines
  807.  
  808. SYNTAX
  809.      Next [relative_target]
  810.  
  811. DESCRIPTION
  812.      The NEXT command moves the current line forwards the number of
  813.      lines specified by the relative_target. This relative_target can 
  814.      only be a positive integer or the character "*". 
  815.  
  816. COMPATIBILITY
  817.      XEDIT: Compatible.
  818.      KEDIT: Compatible.
  819.  
  820. DEFAULT
  821.      1
  822.  
  823. SEE ALSO
  824.      DOWN, UP
  825.  
  826. STATUS
  827.      Complete.
  828. **man-end**********************************************************************/
  829. #ifdef PROTO
  830. short Next(CHARTYPE *params)
  831. #else
  832. short Next(params)
  833. CHARTYPE *params;
  834. #endif
  835. /***********************************************************************/
  836. {
  837. /*-------------------------- external data ----------------------------*/
  838.  extern bool curses_started;
  839. /*--------------------------- local data ------------------------------*/
  840.  unsigned short y=0,x=0;
  841.  short rc=RC_OK;
  842.  LINE *curr=NULL;
  843.  LINETYPE num_lines=0L,true_line=0L;
  844. /*--------------------------- processing ------------------------------*/
  845. #ifdef TRACE
  846.  trace_function("comm3.c:   Next");
  847. #endif
  848.  if (strcmp("",params) == 0)
  849.     params = (CHARTYPE *)"1";
  850.  true_line = get_true_line();
  851.  if (strcmp("*",params) == 0)
  852.     num_lines = CURRENT_FILE->number_lines - true_line + 1L;
  853.  else
  854.    {
  855.     if (!valid_integer(params))
  856.       {
  857.        display_error(4,params,FALSE);
  858. #ifdef TRACE
  859.        trace_return();
  860. #endif
  861.        return(RC_INVALID_OPERAND);
  862.       }
  863.     num_lines = atol(params);
  864.     if (num_lines < 0L)
  865.       {
  866.        display_error(5,params,FALSE);
  867. #ifdef TRACE
  868.        trace_return();
  869. #endif
  870.        return(RC_INVALID_OPERAND);
  871.       }
  872.    }
  873.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  874.     rc = advance_current_line(num_lines);
  875.  else
  876.     rc = advance_focus_line(num_lines);
  877. #ifdef TRACE
  878.  trace_return();
  879. #endif
  880.  return(rc);
  881. }
  882. /*man-start*********************************************************************
  883. COMMAND
  884.      nextwindow - switch focus of editing session to other window
  885.  
  886. SYNTAX
  887.      NEXTWindow
  888.  
  889. DESCRIPTION
  890.      The NEXTWINDOW command moves the focus of the editing session to
  891.      the other window (if more than one window is currently displayed)
  892.      or to the next file in the ring.
  893.  
  894. COMPATIBILITY
  895.      XEDIT: N/A
  896.      KEDIT: N/A
  897.  
  898. SEE ALSO
  899.      EDIT, SCREEN
  900.  
  901. STATUS
  902.      Complete.
  903. **man-end**********************************************************************/
  904. #ifdef PROTO
  905. short Nextwindow(CHARTYPE *params)
  906. #else
  907. short Nextwindow(params)
  908. CHARTYPE *params;
  909. #endif
  910. /***********************************************************************/
  911. {
  912. /*-------------------------- external data ----------------------------*/
  913.  extern CHARTYPE display_screens;
  914.  extern WINDOW *foot;
  915.  extern bool curses_started;
  916. /*--------------------------- local data ------------------------------*/
  917.  short rc=RC_OK;
  918. /*--------------------------- processing ------------------------------*/
  919. #ifdef TRACE
  920.  trace_function("comm3.c:   Nextwindow");
  921. #endif
  922.  if (strcmp(params,"") != 0)
  923.    {
  924.     display_error(1,params,FALSE);
  925. #ifdef TRACE
  926.     trace_return();
  927. #endif
  928.     return(RC_INVALID_OPERAND);
  929.    }
  930.  if (display_screens == 1)
  931.    {
  932.     rc = Xedit((CHARTYPE *)"");
  933. #ifdef TRACE
  934.     trace_return();
  935. #endif
  936.     return(rc);
  937.    }
  938.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  939.  current_screen = (current_screen == 0) ? 1 : 0;
  940.  CURRENT_VIEW = CURRENT_SCREEN.screen_view;
  941.  if (curses_started)
  942.    {
  943.     if (CURRENT_WINDOW_COMMAND != (WINDOW *)NULL)
  944.       {
  945.        wattrset(CURRENT_WINDOW_COMMAND,set_colour(CURRENT_FILE->attr+ATTR_CMDLINE));
  946.        touchwin(CURRENT_WINDOW_COMMAND);
  947.        wnoutrefresh(CURRENT_WINDOW_COMMAND);
  948.       }
  949.     if (CURRENT_WINDOW_ARROW != (WINDOW *)NULL)
  950.       {
  951.        wattrset(CURRENT_WINDOW_ARROW,set_colour(CURRENT_FILE->attr+ATTR_ARROW));
  952.        redraw_window(CURRENT_WINDOW_ARROW);
  953.        wnoutrefresh(CURRENT_WINDOW_ARROW);
  954.       }
  955.     if (foot != (WINDOW *)NULL)
  956.       {
  957.        wattrset(foot,set_colour(CURRENT_FILE->attr+ATTR_STATAREA));
  958.        redraw_window(foot);
  959.       }
  960.     if (CURRENT_WINDOW_IDLINE != (WINDOW *)NULL)
  961.       {
  962.        wattrset(CURRENT_WINDOW_IDLINE,set_colour(CURRENT_FILE->attr+ATTR_IDLINE));
  963.        redraw_window(CURRENT_WINDOW_IDLINE);
  964.       }
  965.    }
  966.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  967.  build_current_screen();
  968.  display_current_screen();
  969.  
  970. #ifdef TRACE
  971.  trace_return();
  972. #endif
  973.  return(RC_OK);
  974. }
  975. /*man-start*********************************************************************
  976. COMMAND
  977.      nomsg - execute a command suppressing any messages 
  978.  
  979. SYNTAX
  980.      NOMSG command [parameters]
  981.  
  982. DESCRIPTION
  983.      The NOMSG command executes the supplied command but suppresses
  984.      messages that would normally be displayed as a result of the 
  985.      command.
  986.  
  987. COMPATIBILITY
  988.      XEDIT: N/A
  989.      KEDIT: Compatible.
  990.  
  991. STATUS
  992.      Complete.
  993. **man-end**********************************************************************/
  994. #ifdef PROTO
  995. short Nomsg(CHARTYPE *params)
  996. #else
  997. short Nomsg(params)
  998. CHARTYPE *params;
  999. #endif
  1000. /***********************************************************************/
  1001. {
  1002. /*-------------------------- external data ----------------------------*/
  1003. /*--------------------------- local data ------------------------------*/
  1004.  bool save_msgmode=CURRENT_VIEW->msgmode_status;
  1005.  short rc=RC_OK;
  1006. /*--------------------------- processing ------------------------------*/
  1007. #ifdef TRACE
  1008.  trace_function("comm3.c:   Nomsg");
  1009. #endif
  1010.  CURRENT_VIEW->msgmode_status = FALSE;
  1011.  rc = command_line(params,COMMAND_ONLY_FALSE);
  1012.  CURRENT_VIEW->msgmode_status = save_msgmode;
  1013. #ifdef TRACE
  1014.  trace_return();
  1015. #endif
  1016.  return(rc);
  1017. }
  1018. /*man-start*********************************************************************
  1019. COMMAND
  1020.      nop - no operation command
  1021.  
  1022. SYNTAX
  1023.      NOP
  1024.  
  1025. DESCRIPTION
  1026.      The NOP command doesn't do anything. It is used as a means of
  1027.      setting a key to do nothing.
  1028.  
  1029. COMPATIBILITY
  1030.      XEDIT: N/A
  1031.      KEDIT: N/A
  1032.  
  1033. SEE ALSO
  1034.      DEFINE
  1035.  
  1036. STATUS
  1037.      Complete.
  1038. **man-end**********************************************************************/
  1039. #ifdef PROTO
  1040. short Nop(CHARTYPE *params)
  1041. #else
  1042. short Nop(params)
  1043. CHARTYPE *params;
  1044. #endif
  1045. /***********************************************************************/
  1046. {
  1047. /*--------------------------- local data ------------------------------*/
  1048. /*--------------------------- processing ------------------------------*/
  1049. #ifdef TRACE
  1050.  trace_function("comm3.c:   Nop");
  1051. #endif
  1052. /*---------------------------------------------------------------------*/
  1053. /* No arguments are allowed; error if any are present.                 */
  1054. /*---------------------------------------------------------------------*/
  1055.  if (strcmp(params,"") != 0)
  1056.    {
  1057.     display_error(1,(CHARTYPE *)params,FALSE);
  1058. #ifdef TRACE
  1059.     trace_return();
  1060. #endif
  1061.     return(RC_INVALID_OPERAND);
  1062.    }
  1063. #ifdef TRACE
  1064.  trace_return();
  1065. #endif
  1066.  return(RC_OK);
  1067. }
  1068. /*man-start*********************************************************************
  1069. COMMAND
  1070.      os - execute an operating system command
  1071.  
  1072. SYNTAX
  1073.      OS [command]
  1074.  
  1075. DESCRIPTION
  1076.      The OS command executes the supplied operating system command 
  1077.      or runs an interactive shell if no command is supplied.
  1078.  
  1079. COMPATIBILITY
  1080.      XEDIT: N/A
  1081.      KEDIT: Equivalent to DOS command.
  1082.  
  1083. SEE ALSO
  1084.      DOS, !
  1085.  
  1086. STATUS
  1087.      Complete.
  1088. **man-end**********************************************************************/
  1089. #ifdef PROTO
  1090. short Os(CHARTYPE *params)
  1091. #else
  1092. short Os(params)
  1093. CHARTYPE *params;
  1094. #endif
  1095. /***********************************************************************/
  1096. {
  1097. /*--------------------------- local data ------------------------------*/
  1098.  short rc=RC_OK;
  1099. /*--------------------------- processing ------------------------------*/
  1100. #ifdef TRACE
  1101.  trace_function("comm3.c:   Os");
  1102. #endif
  1103. /*---------------------------------------------------------------------*/
  1104. /* Execute the supplied parameters as OS commands. Run with output     */
  1105. /* displayed and pause before redrawing the windows.                   */
  1106. /*---------------------------------------------------------------------*/
  1107.  rc = execute_os_command(params,FALSE,TRUE);
  1108. #ifdef TRACE
  1109.  trace_return();
  1110. #endif
  1111.  return(rc);
  1112. }
  1113. /*man-start*********************************************************************
  1114. COMMAND
  1115.      osnowait - execute an operating system command - no prompt
  1116.  
  1117. SYNTAX
  1118.      OSNowait command
  1119.  
  1120. DESCRIPTION
  1121.      The OSNOWAIT command executes the supplied operating system 
  1122.      command not waiting for the user to be prompted once the
  1123.      command has completed.
  1124.  
  1125. COMPATIBILITY
  1126.      XEDIT: N/A
  1127.      KEDIT: Equivalent of DOSNOWAIT command.
  1128.  
  1129. SEE ALSO
  1130.      DOSNOWAIT
  1131.  
  1132. STATUS
  1133.      Complete.
  1134. **man-end**********************************************************************/
  1135. #ifdef PROTO
  1136. short Osnowait(CHARTYPE *params)
  1137. #else
  1138. short Osnowait(params)
  1139. CHARTYPE *params;
  1140. #endif
  1141. /***********************************************************************/
  1142. {
  1143. /*--------------------------- local data ------------------------------*/
  1144.  short rc=RC_OK;
  1145. /*--------------------------- processing ------------------------------*/
  1146. #ifdef TRACE
  1147.  trace_function("comm3.c:   Osnowait");
  1148. #endif
  1149. /*---------------------------------------------------------------------*/
  1150. /* Execute the supplied parameters as OS commands. Run with output     */
  1151. /* displayed but no pause before redrawing the windows.                */
  1152. /*---------------------------------------------------------------------*/
  1153.  if (strcmp(params,"") == 0)                     /* no params....error */
  1154.    {
  1155.     display_error(3,(CHARTYPE *)"",FALSE);
  1156. #ifdef TRACE
  1157.     trace_return();
  1158. #endif
  1159.     return(RC_INVALID_OPERAND);
  1160.    }
  1161.  rc = execute_os_command(params,FALSE,FALSE);
  1162. #ifdef TRACE
  1163.  trace_return();
  1164. #endif
  1165.  return(rc);
  1166. }
  1167. /*man-start*********************************************************************
  1168. COMMAND
  1169.      osquiet - execute an operating system command quietly
  1170.  
  1171. SYNTAX
  1172.      OSQuiet command
  1173.  
  1174. DESCRIPTION
  1175.      The OSQUIET command executes the supplied os command as quietly
  1176.      as possible.
  1177.  
  1178. COMPATIBILITY
  1179.      XEDIT: N/A
  1180.      KEDIT: Equivalent of DOSQUIET command.
  1181.  
  1182. SEE ALSO
  1183.      DOSQUIET
  1184.  
  1185. STATUS
  1186.      Complete.
  1187. **man-end**********************************************************************/
  1188. #ifdef PROTO
  1189. short Osquiet(CHARTYPE *params)
  1190. #else
  1191. short Osquiet(params)
  1192. CHARTYPE *params;
  1193. #endif
  1194. /***********************************************************************/
  1195. {
  1196. /*--------------------------- local data ------------------------------*/
  1197.  short rc=RC_OK;
  1198. /*--------------------------- processing ------------------------------*/
  1199. #ifdef TRACE
  1200.  trace_function("comm3.c:   Osquiet");
  1201. #endif
  1202. /*---------------------------------------------------------------------*/
  1203. /* Execute the supplied parameters as OS commands. Run with no output  */
  1204. /* displayed and no pause before redrawing the windows.                */
  1205. /*---------------------------------------------------------------------*/
  1206.  if (strcmp(params,"") == 0)                     /* no params....error */
  1207.    {
  1208.     display_error(3,(CHARTYPE *)"",FALSE);
  1209. #ifdef TRACE
  1210.     trace_return();
  1211. #endif
  1212.     return(RC_INVALID_OPERAND);
  1213.    }
  1214.  rc = execute_os_command(params,TRUE,FALSE);
  1215. #ifdef TRACE
  1216.  trace_return();
  1217. #endif
  1218.  return(rc);
  1219. }
  1220. /*man-start*********************************************************************
  1221. COMMAND
  1222.      overlaybox - overlay marked box block on current cursor position
  1223.  
  1224. SYNTAX
  1225.      OVERLAYBox
  1226.  
  1227. DESCRIPTION
  1228.      The OVERLAYBOX copies the contents of the marked box block over the
  1229.      characters at the current cursor position or to column 1 of the
  1230.      current line if issued from the command line.
  1231.  
  1232. COMPATIBILITY
  1233.      XEDIT: N/A
  1234.      KEDIT: Compatible.
  1235.  
  1236. SEE ALSO
  1237.      MOVE, COPY
  1238.  
  1239. STATUS
  1240.      Complete.
  1241. **man-end**********************************************************************/
  1242. #ifdef PROTO
  1243. short Overlaybox(CHARTYPE *params)
  1244. #else
  1245. short Overlaybox(params)
  1246. CHARTYPE *params;
  1247. #endif
  1248. /***********************************************************************/
  1249. {
  1250. /*-------------------------- external data ----------------------------*/
  1251.  extern VIEW_DETAILS *vd_mark;
  1252. /*--------------------------- local data ------------------------------*/
  1253. /*--------------------------- processing ------------------------------*/
  1254. #ifdef TRACE
  1255.  trace_function("comm3.c:   Overlaybox");
  1256. #endif
  1257. /*---------------------------------------------------------------------*/
  1258. /* Ensure there are no parameters.                                     */
  1259. /*---------------------------------------------------------------------*/
  1260.  if (strcmp(params,"") != 0)
  1261.    {
  1262.     display_error(1,params,FALSE);
  1263. #ifdef TRACE
  1264.     trace_return();
  1265. #endif
  1266.     return(RC_INVALID_OPERAND);
  1267.    }
  1268. /*---------------------------------------------------------------------*/
  1269. /* Validate marked block, can be in any view.                          */
  1270. /*---------------------------------------------------------------------*/
  1271.  if (marked_block(FALSE) != RC_OK)
  1272.    {
  1273. #ifdef TRACE
  1274.     trace_return();
  1275. #endif
  1276.     return(RC_INVALID_ENVIRON);
  1277.    }
  1278. /*---------------------------------------------------------------------*/
  1279. /* Only allow command for box, column and word blocks.                 */
  1280. /*---------------------------------------------------------------------*/
  1281.  if (MARK_VIEW->mark_type != M_BOX
  1282.  &&  MARK_VIEW->mark_type != M_COLUMN
  1283.  &&  MARK_VIEW->mark_type != M_WORD)
  1284.    {
  1285.     display_error(47,(CHARTYPE *)"",FALSE);
  1286. #ifdef TRACE
  1287.     trace_return();
  1288. #endif
  1289.     return(RC_INVALID_ENVIRON);
  1290.    }
  1291.  box_operations(BOX_C,SOURCE_BLOCK,TRUE,' ');  /* no reset, overlay */
  1292.  
  1293. #ifdef TRACE
  1294.  trace_return();
  1295. #endif
  1296.  return(RC_OK);
  1297. }
  1298.